<template>
  <div id="visualData9">
    <!-- 标题和选择框同一行 -->
    <div class="header">
      <div class="gradient-divider">样品成分特征对比 WT202508013系列</div>
      <div class="selectors">
        <!-- 分组选择 -->
        <div class="selector">
          <label>选择分组：</label>
          <select v-model="currentGroup" @change="updateCharts">
            <option v-for="(v, key) in groups" :key="key" :value="key">
              {{ key }}
            </option>
          </select>
        </div>
        <!-- 样区选择 -->
        <div class="selector">
          <label>选择样区：</label>
          <select v-model="currentSample" @change="updateCharts">
            <option v-for="n in 16" :key="n" :value="`样区${n}`">
              样区{{ n }}
            </option>
          </select>
        </div>
      </div>
    </div>

    <!-- 雷达图容器 -->
    <div class="radar-container">
      <div v-for="id in chartIds" :key="id" :id="id" class="radar"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "VisualDataRadar",
  data() {
    return {
      currentGroup: "理化指标",
      currentSample: "样区1",
      chartIds: ["radar1", "radar2", "radar3", "radar4"],

      // 分组定义
      groups: {
        "理化指标": [
          "pH", "淀粉%", "二氯甲烷提取物%", "茄尼醇mg/g",
          "硫酸根mg/g", "磷酸根mg/g", "Mg%", "Ca%", "氯%"
        ],
        "有机酸+脂肪酸": [
          "新绿原酸mg/g", "绿原酸mg/g", "隐绿原酸mg/g", "莨菪亭mg/g",
          "芸香苷mg/g", "乙二酸mg/g", "丙二酸mg/g", "丁二酸mg/g",
          "苹果酸mg/g", "柠檬酸mg/g", "香草酸mg/g",
          "十四酸mg/g", "十六酸mg/g", "亚油酸mg/g", "油酸+亚麻酸mg/g",
          "十八酸mg/g","二十酸mg/g"
        ],
        "氨基酸": [
          "天冬氨酸μg/g", "苏氨酸μg/g", "丝氨酸μg/g", "天冬酰胺μg/g",
          "谷氨酸μg/g", "谷酰胺μg/g", "甘氨酸μg/g", "丙氨酸μg/g",
          "缬氨酸μg/g", "胱氨酸μg/g", "蛋氨酸μg/g", "异亮氨酸μg/g",
          "亮氨酸μg/g", "酪氨酸μg/g", "苯丙氨酸μg/g",
          "4-氨基丁酸μg/g", "赖氨酸μg/g", "组氨酸μg/g",
          "色氨酸μg/g", "精氨酸μg/g", "脯氨酸μg/g"
        ]
      },

      // ✅ 每个样区分组存储
      seriesData: {
        "样区1": {
          "理化指标": {
            C3F: [0.18, 5.43, 10.13, 4.17, 7.44, 5.85, 5.80, 0.22, 2.17],
            B2F: [0.10, 5.38, 8.54, 3.59, 5.81, 4.98, 4.48, 0.12, 2.71],
            X2F: [0.26, 5.22, 8.11, 4.87, 12.10, 4.70, 5.22, 0.27, 2.64]
          },
          "有机酸+脂肪酸": {
            C3F: [1.54, 16.14, 2.51, 0.18, 13.02, 15.8, 3.09, 0.148, 34.8, 1.85, 0.143, 0.138, 3.38, 2.05, 5.31, 0.74, 0.15],
            B2F: [1.67, 13.85, 2.62, 0.12, 9.53, 13.1, 2.49, 0.210, 48.0, 3.20, 0.106, 0.108, 3.36, 1.99, 5.67, 0.71, 0.13],
            X2F: [1.41, 13.10, 2.22, 0.23, 13.22, 16.9, 3.34, 0.162, 43.0, 4.17, 0.142, 0.153, 3.18, 2.28, 4.94, 0.66, 0.15]
          },
          "氨基酸": {
            C3F: [220.9, 63.0, 220.4, 419.2, 104.1, 430.1, 25.4, 495.5, 388.9, 57.9, 17.9, 10.01, 24.9, 52.0, 165.2, 176.1, 30.3, 89.4, 195.2, 39.4, 5889],
            B2F: [203.0, 28.7, 209.2, 199.1, 92.9, 135.0, 23.4, 395.6, 391.7, 50.1, 12.4, 9.81, 23.4, 42.4, 53.9, 137.1, 9.9, 29.7, 64.1, 15.4, 2957],
            X2F: [250.9, 59.4, 238.6, 943.5, 152.7, 768.2, 39.1, 574.9, 367.7, 50.0, 16.4, 7.09, 28.0, 59.8, 167.6, 208.7, 34.6, 149.7, 212.9, 43.4, 7291]
          }
        },
        "样区2": {
          "理化指标": {
            C3F: [0.15, 5.49, 10.18, 3.84, 5.85, 5.93, 4.95, 0.20, 2.78],
            B2F: [0.21, 5.33, 8.65, 5.04, 12.74, 5.10, 5.21, 0.25, 2.83],
            X2F: [0.22, 5.48, 2.98, 3.60, 2.96, 6.30, 4.29, 0.27, 4.93]
          },
          "有机酸+脂肪酸": {
            C3F: [1.79, 18.02, 2.95, 0.09, 10.15, 13.8, 2.62, 0.205, 41.1, 2.37, 0.128, 0.122, 3.39, 1.92, 5.73, 0.74, 0.15],
            B2F: [1.39, 14.35, 2.19, 0.26, 12.59, 15.4, 3.67, 0.162, 45.0, 5.02, 0.170, 0.162, 3.15, 2.26, 4.88, 0.63, 0.14],
            X2F: [2.51, 13.93, 3.89, 0.24, 7.70, 16.4, 2.77, 0.266, 106.8, 10.1, 0.133, 0.091, 2.91, 1.32, 4.99, 0.65, 0.18]
          },
          "氨基酸": {
            C3F: [248.0, 53.6, 185.8, 197.7, 80.9, 342.0, 27.2, 465.8, 383.2, 54.6, 14.9, 9.54, 16.3, 47.3, 130.9, 153.5, 17.7, 46.3, 133.5, 34.0, 3022],
            B2F: [289.4, 67.1, 247.9, 1069, 187.0, 774.9, 41.2, 569.9, 376.8, 53.6, 17.7, 8.21, 29.7, 58.9, 175.7, 217.1, 32.8, 139.1, 197.7, 43.5, 5920],
            X2F: [427.9, 82.6, 343.9, 1251, 253.4, 717.8, 32.2, 342.9, 467.6, 44.6, 17.0, 16.98, 18.3, 70.4, 238.1, 201.0, 12.8, 121.8, 220.9, 23.9, 3006]
          }
        },
        "样区3": {
          "理化指标": {
            C3F: [0.19, 5.29, 9.86, 4.48, 8.95, 5.71, 5.30, 0.21, 2.40],
            B2F: [0.29, 5.21, 7.71, 5.41, 13.80, 5.36, 4.51, 0.24, 2.62],
            X2F: [0.16, 5.37, 3.20, 3.77, 4.15, 5.88, 3.74, 0.22, 4.76]
          },
          "有机酸+脂肪酸": {
            C3F: [1.41, 13.46, 2.18, 0.17, 12.18, 16.8, 2.90, 0.174, 30.1, 2.09, 0.121, 0.131, 3.28, 2.12, 5.18, 0.73, 0.15],
            B2F: [1.40, 11.91, 2.07, 0.24, 12.23, 16.6, 3.42, 0.176, 37.9, 3.89, 0.148, 0.158, 3.22, 2.39, 4.96, 0.68, 0.15],
            X2F: [2.56, 13.07, 3.92, 0.20, 9.24, 15.9, 2.57, 0.290, 107.8, 10.29, 0.112, 0.090, 2.96, 1.35, 5.25, 0.66, 0.17]
          },
          "氨基酸": {
            C3F: [256.7, 53.4, 227.9, 817.6, 160.5, 581.9, 35.4, 559.0, 402.2, 54.3, 13.4, 7.42, 20.4, 59.2, 155.0, 197.1, 29.0, 104.6, 192.3, 38.0, 6505],
            B2F: [263.4, 49.7, 228.2, 1123.4, 167.6, 798.3, 42.6, 590.0, 373.3, 46.3, 15.1, 8.44, 36.0, 57.8, 150.5, 228.4, 24.4, 134.1, 204.0, 37.5, 6755],
            X2F: [448.8, 81.8, 313.3, 1197.2, 291.9, 778.1, 37.6, 398.7, 449.6, 44.8, 12.7, 14.34, 11.0, 70.2, 237.3, 221.7, 17.3, 120.9, 228.6, 24.3, 3011]
          }
        },
        "样区4": {
          "理化指标": {
            "C3F": [0.15, 5.38, 9.86, 4.19, 8.21, 5.01, 4.08, 0.11, 2.7],
            "B2F": [0.21, 5.22, 9.81, 5.18, 13.73, 4.5, 4.51, 0.19, 2.31],
            "X2F": [0.23, 5.37, 7.29, 3.8, 4.77, 7.67, 4.93, 0.17, 2.86]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.41, 11.6, 2.22, 0.13, 8.17, 14.1, 2.85, 0.196, 47.4, 2.82, 0.107, 0.117, 3.24, 2.07, 5.34, 0.73, 0.15],
            "B2F": [0.99, 10.61, 1.48, 0.26, 9.48, 13.6, 3.43, 0.165, 38.1, 3.69, 0.145, 0.159, 3.2, 2.45, 4.95, 0.63, 0.14],
            "X2F": [1.95, 16.77, 3.18, 0.13, 8.78, 14.3, 2.29, 0.232, 47.2, 2.93, 0.111, 0.109, 3.44, 1.86, 5.85, 0.74, 0.15]
          },
          "氨基酸": {
            "C3F": [248.0, 45.9, 186.2, 451.0, 117.7, 364.9, 31.9, 527.9, 401.4, 54.1, 13.9, 9.43, 20.1, 45.4, 127.1, 186.3, 17.4, 61.6, 153.4, 28.9, 4057.0],
            "B2F": [254.9, 53.9, 237.4, 1050.8, 139.6, 627.6, 32.7, 569.8, 400.1, 57.6, 19.6, 8.51, 36.8, 51.0, 124.5, 204.0, 27.9, 111.2, 148.0, 40.2, 6532.0],
            "X2F": [214.9, 31.0, 197.4, 197.8, 100.7, 99.5, 19.1, 371.7, 369.0, 50.6, 17.1, 10.77, 20.4, 42.1, 64.9, 132.8, 9.8, 29.5, 48.5, 11.5, 3028.0]
          }
        },
        "样区5": {
          "理化指标": {
            "C3F": [0.14, 5.42, 10.07, 3.63, 6.87, 4.64, 4.81, 0.11, 2.25],
            "B2F": [0.25, 5.34, 10.2, 4.69, 8.7, 6.56, 4.82, 0.14, 2.49],
            "X2F": [0.37, 5.4, 4.89, 4.08, 6.02, 7.16, 3.89, 0.17, 3.68]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.18, 15.12, 2.05, 0.09, 10.05, 13.6, 2.47, 0.15, 30.5, 1.2, 0.116, 0.12, 3.51, 2.01, 5.82, 0.73, 0.14],
            "B2F": [1.3, 13.51, 2.02, 0.21, 10.01, 16.7, 3.08, 0.148, 23.6, 2.16, 0.139, 0.14, 3.31, 2.14, 5.28, 0.74, 0.15],
            "X2F": [2.05, 12.96, 3.05, 0.18, 4.98, 14.6, 2.7, 0.287, 69.1, 6.81, 0.121, 0.109, 3.08, 1.68, 4.93, 0.69, 0.16]
          },
          "氨基酸": {
            "C3F": [142.1, 42.0, 181.6, 202.7, 49.9, 365.3, 18.6, 490.0, 401.5, 54.5, 16.3, 9.46, 31.3, 44.8, 104.8, 138.9, 21.1, 48.1, 138.4, 34.4, 3504.0],
            "B2F": [197.7, 44.0, 221.2, 756.8, 123.3, 646.6, 33.3, 567.5, 394.5, 55.8, 18.8, 7.55, 29.6, 47.7, 113.0, 196.2, 21.6, 78.7, 142.7, 38.2, 6417.0],
            "X2F": [333.8, 58.2, 251.4, 861.4, 201.9, 380.1, 31.0, 423.5, 381.6, 44.1, 18.8, 10.87, 30.8, 51.4, 166.0, 210.7, 9.9, 71.3, 143.7, 23.1, 2993.0]
          }
        },
        "样区6": {
          "理化指标": {
            "C3F": [0.16, 5.38, 9.67, 4.36, 8.87, 5.6, 4.85, 0.19, 2.29],
            "B2F": [0.2, 5.24, 9.48, 5.24, 14.02, 5.18, 4.11, 0.21, 2.43],
            "X2F": [0.2, 5.44, 5.93, 3.74, 4.82, 6.0, 3.87, 0.16, 3.5]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.34, 13.02, 2.06, 0.18, 8.55, 14.4, 3.15, 0.176, 36.8, 2.43, 0.125, 0.132, 3.32, 2.09, 5.36, 0.73, 0.15],
            "B2F": [1.15, 11.29, 1.76, 0.24, 9.75, 13.7, 3.4, 0.152, 43.7, 4.4, 0.151, 0.162, 3.17, 2.3, 5.0, 0.63, 0.14],
            "X2F": [2.1, 13.62, 3.12, 0.19, 7.43, 13.3, 2.7, 0.251, 74.7, 6.1, 0.108, 0.099, 3.13, 1.76, 5.19, 0.69, 0.15]
          },
          "氨基酸": {
            "C3F": [264.3, 57.0, 238.2, 741.9, 133.1, 572.5, 31.1, 557.3, 414.1, 56.2, 19.3, 9.73, 33.1, 52.1, 148.5, 215.7, 27.2, 93.5, 178.1, 36.8, 6241.0],
            "B2F": [256.7, 57.9, 228.4, 1233.6, 166.3, 864.8, 39.1, 594.9, 369.0, 56.9, 17.3, 9.34, 29.6, 49.6, 154.6, 216.5, 32.6, 141.5, 189.0, 41.1, 6476.0],
            "X2F": [329.4, 50.3, 255.3, 487.6, 176.3, 408.7, 32.7, 446.5, 411.4, 46.9, 11.2, 10.6, 11.4, 46.5, 134.7, 188.8, 10.0, 62.8, 126.4, 16.0, 2999.0]
          }
        },
        "样区7": {
          "理化指标": {
            "C3F": [0.18, 5.39, 8.96, 4.36, 8.28, 6.72, 5.42, 0.17, 2.11],
            "B2F": [0.31, 5.26, 7.55, 5.34, 13.55, 6.5, 5.15, 0.25, 2.04],
            "X2F": [0.31, 5.41, 2.65, 3.61, 4.58, 6.46, 3.91, 0.29, 3.99]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.28, 12.31, 1.97, 0.22, 9.65, 14.7, 3.19, 0.149, 38.6, 2.24, 0.14, 0.144, 3.33, 2.16, 5.22, 0.72, 0.14],
            "B2F": [1.16, 11.76, 1.79, 0.31, 12.4, 14.4, 3.67, 0.151, 43.0, 4.44, 0.174, 0.183, 3.27, 2.39, 5.0, 0.64, 0.14],
            "X2F": [2.25, 12.35, 3.44, 0.17, 6.56, 14.3, 2.59, 0.26, 102.3, 8.32, 0.11, 0.091, 3.0, 1.41, 4.85, 0.65, 0.17]
          },
          "氨基酸": {
            "C3F": [209.5, 61.2, 255.2, 658.5, 146.8, 518.9, 26.2, 527.3, 392.5, 67.6, 19.7, 9.76, 29.6, 49.2, 152.5, 206.9, 31.5, 96.3, 175.0, 38.3, 7548.0],
            "B2F": [239.8, 72.8, 254.9, 1223.0, 178.7, 829.2, 33.5, 586.6, 376.8, 62.8, 20.0, 11.42, 34.8, 52.1, 183.8, 241.3, 42.1, 165.0, 224.6, 46.6, 9008.0],
            "X2F": [334.8, 81.4, 291.8, 1106.1, 235.7, 723.1, 32.5, 428.2, 381.1, 42.6, 17.0, 13.71, 17.3, 57.4, 228.7, 202.5, 14.4, 144.9, 252.4, 20.7, 3764.0]
          }
        },
        "样区8": {
          "理化指标": {
            "C3F": [0.18, 5.39, 8.97, 4.46, 8.55, 5.86, 4.52, 0.18, 3.03],
            "B2F": [0.12, 5.3, 7.48, 5.79, 13.96, 5.83, 4.87, 0.18, 2.69],
            "X2F": [0.25, 5.31, 4.61, 3.82, 5.59, 5.07, 3.39, 0.21, 3.6]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.78, 12.34, 2.64, 0.1, 8.72, 14.0, 2.66, 0.243, 50.3, 3.36, 0.126, 0.123, 3.24, 2.01, 5.34, 0.72, 0.16],
            "B2F": [1.19, 9.48, 1.6, 0.37, 8.3, 13.2, 3.99, 0.184, 41.9, 4.71, 0.169, 0.173, 3.05, 2.51, 4.77, 0.64, 0.15],
            "X2F": [2.15, 10.81, 3.03, 0.18, 4.18, 15.6, 2.72, 0.306, 82.8, 7.31, 0.106, 0.091, 3.05, 1.78, 4.83, 0.68, 0.16]
          },
          "氨基酸": {
            "C3F": [229.6, 36.5, 216.3, 363.0, 109.7, 333.2, 36.5, 497.4, 423.3, 53.8, 11.6, 8.92, 15.3, 43.8, 112.3, 174.3, 9.9, 48.5, 127.7, 24.1, 3137.0],
            "B2F": [334.0, 58.4, 271.7, 1838.9, 223.6, 850.1, 50.4, 647.4, 440.9, 57.3, 18.1, 10.42, 22.1, 58.4, 153.1, 270.3, 31.4, 138.1, 179.9, 43.7, 7270.0],
            "X2F": [425.2, 69.4, 296.8, 1098.0, 294.1, 576.3, 36.7, 482.4, 445.0, 40.4, 16.2, 10.85, 24.2, 65.2, 198.0, 249.2, 10.1, 108.7, 203.0, 17.8, 3908.0]
          }
        },
        "样区9": {
          "理化指标": {
            "C3F": [0.18, 5.35, 10.06, 4.36, 8.74, 6.51, 5.23, 0.16, 2.31],
            "B2F": [0.3, 5.27, 6.48, 5.46, 14.23, 6.64, 4.81, 0.24, 2.65],
            "X2F": [0.27, 5.41, 6.45, 3.74, 5.75, 5.86, 2.99, 0.17, 3.76]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.37, 13.67, 2.12, 0.18, 10.26, 15.0, 2.89, 0.152, 29.6, 1.92, 0.141, 0.143, 3.39, 2.05, 5.37, 0.72, 0.15],
            "B2F": [1.46, 13.6, 2.15, 0.27, 12.47, 15.2, 3.86, 0.176, 43.0, 5.4, 0.159, 0.177, 3.21, 2.41, 4.99, 0.63, 0.14],
            "X2F": [2.16, 13.84, 3.31, 0.13, 6.45, 14.5, 2.23, 0.244, 73.7, 7.06, 0.114, 0.099, 3.14, 1.53, 5.64, 0.69, 0.16]
          },
          "氨基酸": {
            "C3F": [221.2, 58.5, 251.5, 555.9, 114.1, 555.7, 31.1, 528.6, 415.3, 61.0, 18.2, 9.51, 26.7, 51.5, 151.0, 193.0, 32.6, 97.0, 186.3, 42.4, 7346.0],
            "B2F": [304.5, 69.8, 266.6, 1713.3, 236.7, 1162.8, 43.6, 678.9, 377.5, 56.7, 20.1, 8.8, 32.8, 64.8, 206.7, 294.1, 40.3, 190.1, 221.0, 47.3, 8591.0],
            "X2F": [259.4, 53.1, 260.1, 289.1, 145.3, 415.9, 26.3, 372.5, 412.8, 46.5, 11.3, 10.19, 31.2, 45.7, 132.7, 160.4, 9.9, 54.9, 153.1, 21.5, 2970.0]
          }
        },
        "样区10": {
          "理化指标": {
            "C3F": [0.17, 5.46, 9.97, 3.78, 6.82, 5.42, 4.64, 0.13, 2.43],
            "B2F": [0.24, 5.26, 6.73, 5.79, 16.62, 5.95, 4.1, 0.21, 2.8],
            "X2F": [0.19, 5.34, 4.76, 3.81, 5.0, 5.14, 3.52, 0.23, 4.44]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.52, 13.24, 2.47, 0.15, 8.7, 12.2, 2.66, 0.184, 56.6, 3.72, 0.142, 0.128, 3.4, 1.89, 5.56, 0.71, 0.15],
            "B2F": [1.29, 11.0, 1.84, 0.26, 9.7, 13.1, 3.78, 0.176, 47.0, 5.89, 0.164, 0.184, 3.13, 2.39, 4.94, 0.63, 0.14],
            "X2F": [2.27, 12.62, 3.29, 0.18, 6.58, 15.2, 2.59, 0.267, 88.5, 7.81, 0.122, 0.095, 3.05, 1.52, 5.15, 0.7, 0.18]
          },
          "氨基酸": {
            "C3F": [239.0, 73.0, 214.4, 199.1, 96.2, 270.5, 24.7, 457.5, 405.2, 64.6, 19.6, 12.11, 23.6, 43.1, 170.7, 170.3, 26.1, 60.4, 185.6, 35.6, 3910.0],
            "B2F": [328.5, 71.5, 261.0, 1755.6, 205.8, 1081.3, 44.4, 630.2, 388.2, 59.1, 19.0, 9.29, 33.8, 60.8, 200.8, 271.4, 44.6, 180.4, 222.9, 50.7, 8109.0],
            "X2F": [420.1, 78.8, 302.3, 1097.3, 253.6, 740.1, 45.4, 489.9, 472.0, 48.4, 11.7, 12.76, 19.9, 65.5, 225.4, 246.8, 19.6, 115.6, 249.4, 27.1, 2946.0]
          }
        },
        "样区11": {
          "理化指标": {
            "C3F": [0.2, 5.39, 7.75, 4.81, 10.57, 5.83, 4.88, 0.17, 2.36],
            "B2F": [0.28, 5.18, 6.35, 5.85, 15.34, 5.91, 4.05, 0.25, 2.59],
            "X2F": [0.26, 5.34, 4.08, 4.45, 7.86, 5.06, 3.33, 0.24, 3.83]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.68, 13.1, 2.58, 0.17, 9.23, 12.9, 3.27, 0.239, 50.6, 2.88, 0.142, 0.143, 3.44, 2.28, 5.69, 0.74, 0.16],
            "B2F": [1.32, 10.22, 1.82, 0.33, 9.75, 14.6, 3.92, 0.209, 39.7, 5.6, 0.151, 0.174, 3.16, 2.52, 4.96, 0.65, 0.16],
            "X2F": [2.17, 12.31, 3.09, 0.22, 4.98, 14.8, 2.87, 0.262, 72.5, 5.9, 0.14, 0.116, 3.23, 1.94, 5.25, 0.72, 0.17]
          },
          "氨基酸": {
            "C3F": [273.1, 59.1, 197.0, 356.2, 142.4, 196.8, 27.8, 511.7, 417.1, 52.5, 16.8, 11.26, 21.6, 46.6, 160.0, 200.9, 17.8, 61.0, 164.9, 30.1, 3140.0],
            "B2F": [354.1, 68.9, 287.4, 2126.6, 285.0, 1215.7, 53.1, 732.0, 453.9, 55.4, 20.1, 7.61, 32.5, 68.8, 199.1, 322.9, 40.5, 187.8, 223.6, 50.3, 8473.0],
            "X2F": [329.9, 51.6, 272.8, 410.7, 188.7, 243.7, 40.5, 424.4, 477.1, 46.1, 13.4, 11.86, 24.2, 48.1, 129.4, 199.5, 10.0, 41.1, 144.1, 13.7, 2972.0]
          }
        },
        "样区12": {
          "理化指标": {
            "C3F": [0.17, 5.42, 7.3, 5.02, 10.41, 7.49, 5.55, 0.18, 2.62],
            "B2F": [0.24, 5.23, 8.22, 5.48, 15.34, 5.18, 3.9, 0.2, 2.76],
            "X2F": [0.2, 5.44, 4.87, 3.67, 4.41, 5.17, 3.95, 0.19, 4.1]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.47, 10.89, 2.1, 0.25, 9.85, 14.4, 3.48, 0.205, 43.9, 3.34, 0.146, 0.153, 3.15, 2.19, 4.87, 0.71, 0.15],
            "B2F": [1.33, 11.98, 1.9, 0.22, 9.48, 12.4, 3.3, 0.155, 44.1, 3.88, 0.159, 0.172, 3.21, 2.31, 5.22, 0.65, 0.15],
            "X2F": [2.22, 13.23, 3.28, 0.19, 5.04, 14.8, 2.6, 0.263, 85.9, 7.24, 0.124, 0.095, 3.06, 1.63, 5.03, 0.69, 0.17]
          },
          "氨基酸": {
            "C3F": [316.4, 65.4, 249.2, 1373.8, 208.2, 677.8, 39.4, 587.2, 418.6, 64.7, 18.5, 10.8, 19.2, 54.7, 190.9, 253.5, 35.6, 122.6, 191.1, 40.7, 7277.0],
            "B2F": [262.2, 61.1, 261.5, 1211.5, 155.8, 887.2, 40.6, 592.9, 420.3, 60.7, 15.1, 7.83, 35.7, 55.6, 167.2, 213.0, 34.6, 143.6, 202.3, 43.5, 7829.0],
            "X2F": [398.5, 75.7, 285.2, 957.2, 219.6, 553.6, 38.2, 448.6, 466.7, 51.2, 14.1, 14.62, 18.6, 61.8, 199.5, 215.6, 12.1, 97.0, 205.5, 21.4, 3714.0]
          }
        },
        "样区13": {
          "理化指标": {
            "C3F": [0.25, 5.36, 8.39, 4.44, 8.18, 6.26, 3.72, 0.2, 3.2],
            "B2F": [0.26, 5.24, 7.4, 5.89, 14.86, 5.98, 4.49, 0.25, 2.62],
            "X2F": [0.57, 5.51, 1.5, 3.92, 3.69, 6.98, 2.33, 0.4, 5.06]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.8, 11.1, 2.66, 0.13, 5.93, 14.5, 2.66, 0.248, 55.6, 4.24, 0.124, 0.114, 3.34, 1.98, 5.79, 0.74, 0.17],
            "B2F": [1.24, 10.79, 1.76, 0.34, 9.97, 15.2, 3.93, 0.169, 36.5, 4.62, 0.173, 0.18, 3.18, 2.51, 5.1, 0.65, 0.16],
            "X2F": [2.69, 9.49, 3.81, 0.24, 4.06, 19.3, 3.04, 0.293, 122.3, 16.58, 0.126, 0.09, 2.53, 1.21, 4.12, 0.6, 0.2]
          },
          "氨基酸": {
            "C3F": [272.2, 46.0, 220.8, 561.3, 145.9, 363.0, 33.5, 501.9, 469.0, 52.0, 15.6, 13.04, 30.5, 50.3, 135.7, 206.7, 10.0, 44.2, 146.3, 17.8, 2988.0],
            "B2F": [283.2, 59.4, 280.8, 1854.9, 219.4, 994.3, 49.6, 689.2, 453.4, 61.1, 19.3, 10.52, 32.5, 61.0, 156.3, 271.9, 34.0, 153.5, 201.5, 46.9, 8343.0],
            "X2F": [554.6, 129.3, 451.1, 3526.0, 451.9, 1838.2, 56.9, 585.4, 526.5, 41.3, 14.3, 22.21, 7.6, 98.8, 435.7, 363.5, 40.4, 301.5, 395.1, 36.7, 3322.0]
          }
        },
        "样区14": {
          "理化指标": {
            "C3F": [0.05, 5.23, 8.19, 3.98, 8.61, 4.2, 4.29, 0.2, 3.08],
            "B2F": [0.14, 5.42, 8.25, 4.27, 7.97, 5.72, 4.03, 0.13, 3.21],
            "X2F": [0.29, 5.38, 1.81, 4.15, 6.21, 5.65, 2.49, 0.24, 4.85]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.74, 12.47, 2.62, 0.1, 8.45, 13.5, 2.47, 0.239, 68.7, 3.69, 0.106, 0.111, 3.26, 2.06, 5.67, 0.71, 0.15],
            "B2F": [1.5, 11.08, 2.16, 0.19, 6.38, 12.5, 3.05, 0.179, 49.5, 3.88, 0.13, 0.132, 3.28, 1.97, 5.53, 0.71, 0.15],
            "X2F": [2.53, 9.91, 3.56, 0.2, 4.62, 16.9, 2.95, 0.323, 109.7, 11.21, 0.114, 0.091, 2.72, 1.47, 4.55, 0.65, 0.19]
          },
          "氨基酸": {
            "C3F": [320.7, 67.1, 228.9, 599.2, 170.5, 508.7, 31.1, 499.0, 449.1, 57.2, 13.3, 11.45, 23.5, 60.8, 185.5, 198.4, 29.0, 96.9, 210.4, 31.8, 4511.0],
            "B2F": [267.0, 56.9, 265.3, 816.2, 147.6, 651.1, 41.0, 564.4, 470.2, 65.1, 17.1, 9.78, 25.9, 49.4, 128.4, 226.3, 23.6, 67.2, 158.1, 34.4, 5909.0],
            "X2F": [496.7, 91.5, 359.6, 2354.9, 365.0, 1137.8, 44.7, 475.0, 464.7, 41.6, 14.8, 15.42, 23.6, 81.5, 304.1, 290.7, 24.0, 190.6, 310.9, 27.5, 3634.0]
          }
        },
        "样区15": {
          "理化指标": {
            "C3F": [0.22, 5.28, 9.34, 4.27, 8.56, 5.82, 4.48, 0.17, 2.65],
            "B2F": [0.2, 5.22, 6.54, 5.62, 14.39, 5.79, 3.75, 0.26, 2.83],
            "X2F": [0.2, 5.38, 6.65, 3.92, 6.72, 5.71, 3.42, 0.15, 3.79]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.33, 11.7, 1.92, 0.16, 7.31, 14.0, 2.82, 0.183, 37.5, 2.13, 0.109, 0.124, 3.24, 2.2, 5.34, 0.73, 0.15],
            "B2F": [1.21, 8.56, 1.65, 0.31, 10.1, 14.9, 3.82, 0.192, 44.3, 5.27, 0.146, 0.166, 3.05, 2.43, 4.66, 0.65, 0.15],
            "X2F": [2.02, 12.9, 2.95, 0.13, 6.62, 14.6, 2.51, 0.247, 72.2, 5.81, 0.107, 0.107, 3.1, 1.87, 5.25, 0.69, 0.15]
          },
          "氨基酸": {
            "C3F": [232.0, 45.6, 258.3, 842.6, 158.1, 672.0, 32.8, 589.8, 441.4, 58.7, 18.1, 7.02, 32.0, 55.2, 116.8, 215.6, 23.2, 80.6, 139.0, 34.3, 6943.0],
            "B2F": [314.1, 54.0, 265.3, 1867.2, 203.0, 975.7, 44.8, 608.1, 399.9, 51.9, 18.6, 10.22, 40.3, 64.5, 162.3, 272.3, 32.6, 154.0, 200.8, 41.9, 7785.0],
            "X2F": [275.0, 40.4, 243.9, 331.0, 164.6, 360.7, 28.2, 424.5, 410.0, 46.4, 12.8, 7.39, 19.9, 48.5, 116.5, 172.3, 10.0, 47.8, 114.0, 16.9, 3294.0]
          }
        },
        "样区16": {
          "理化指标": {
            "C3F": [0.17, 5.38, 7.92, 4.11, 8.83, 4.88, 4.36, 0.15, 2.76],
            "B2F": [0.37, 5.23, 5.85, 5.78, 17.02, 4.82, 3.82, 0.23, 3.02],
            "X2F": [0.22, 5.29, 3.3, 4.11, 6.4, 5.86, 3.11, 0.18, 4.0]
          },
          "有机酸+脂肪酸": {
            "C3F": [1.68, 12.33, 2.58, 0.17, 9.0, 13.4, 2.87, 0.215, 66.8, 4.49, 0.131, 0.127, 3.29, 2.05, 5.6, 0.7, 0.15],
            "B2F": [1.27, 8.61, 1.63, 0.29, 8.65, 12.6, 3.68, 0.222, 59.1, 6.64, 0.154, 0.175, 2.96, 2.6, 4.86, 0.58, 0.14],
            "X2F": [2.35, 11.97, 3.36, 0.2, 4.89, 16.0, 2.83, 0.306, 86.7, 8.21, 0.119, 0.102, 2.9, 1.76, 4.54, 0.67, 0.17]
          },
          "氨基酸": {
            "C3F": [321.8, 77.2, 231.0, 493.4, 190.5, 341.0, 30.0, 487.0, 426.4, 63.7, 17.0, 10.18, 24.8, 49.0, 189.9, 210.8, 27.1, 85.8, 200.8, 32.6, 4304.0],
            "B2F": [308.5, 65.9, 268.4, 1981.4, 239.4, 928.3, 45.7, 575.6, 433.8, 63.3, 16.0, 10.1, 29.5, 57.2, 167.3, 252.6, 33.0, 148.2, 169.5, 42.4, 7123.0],
            "X2F": [502.4, 79.4, 287.5, 1777.7, 331.7, 850.1, 46.3, 484.3, 421.7, 51.5, 14.4, 13.05, 15.9, 72.7, 257.9, 269.5, 20.4, 151.0, 249.3, 25.6, 3772.0]
          }
        },
        // ... 样区3 - 样区16 类似结构
      }
    };
  },
  mounted() {
    this.updateCharts();
  },
  methods: {
    updateCharts() {
      const indicators = this.groups[this.currentGroup];
      const chunkSize = Math.ceil(indicators.length / 4);
      const sampleData = this.seriesData[this.currentSample][this.currentGroup];

      this.chartIds.forEach((id, idx) => {
        const dom = document.getElementById(id);
        if (!dom) return;
        const chart = echarts.init(dom);

        const subIndicators = indicators.slice(idx * chunkSize, (idx + 1) * chunkSize);
        if (subIndicators.length === 0) {
          chart.clear();
          return;
        }

        // ✅ 每个雷达图单独计算 max
        let allVals = [];
        subIndicators.forEach((_, i) => {
          allVals.push(
            sampleData.C3F[idx * chunkSize + i],
            sampleData.B2F[idx * chunkSize + i],
            sampleData.X2F[idx * chunkSize + i]
          );
        });
        const subMax = Math.max(...allVals) * 1.2 || 1;

        chart.setOption({
          tooltip: { trigger: "item" },
          legend: {
            data: ["C3F", "B2F", "X2F"],
            bottom: 0,
            textStyle: { color: "#fff" }
          },
          radar: {
            radius: subIndicators.length <= 3 ? "65%" : "55%",
            indicator: subIndicators.map((name, i) => ({
              name,
              max: subMax
            })),
            splitLine: { lineStyle: { color: "#777" } },
            axisLine: { lineStyle: { color: "#999" } }
          },
          series: [
            {
              type: "radar",
              data: [
                { name: "C3F", value: sampleData.C3F.slice(idx * chunkSize, (idx + 1) * chunkSize) },
                { name: "B2F", value: sampleData.B2F.slice(idx * chunkSize, (idx + 1) * chunkSize) },
                { name: "X2F", value: sampleData.X2F.slice(idx * chunkSize, (idx + 1) * chunkSize) }
              ]
            }
          ]
        });
      });
    }
  }
};
</script>


<style scoped>
#visualData9 {
  height: 496px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* 标题和选择框同一行 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gradient-divider {
  font-size: 17px;
  font-weight: bold;
  color: #f3f1f1;
  background: linear-gradient(to right, rgb(24, 115, 164) 0%, transparent);
  padding: 0 10px;
  height: 28px;
  display: flex;
  align-items: center;
  border-radius: 3px;
}

/* 选择框透明化 */
.selectors {
  display: flex;
  gap: 10px;
  margin-right: 10px;
}
.selector {
  color: #fff;
}
.selector select {
  background: rgba(255, 255, 255, 0.1); /* 半透明背景 */
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 2px 6px;
  border-radius: 5px;
  outline: none;
  font-size: 12px;
}

/* 下拉展开的内容 */
.selector select option {
  background: #1e1e1e; /* 深色背景 */
  color: #fff;         /* 白色文字 */
}

.radar-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
}
.radar {
  width: 100%;
  height: 100%;
}
</style>
